package com.baizhi.service.impl;

import com.baizhi.annotation.AddCacheAnnotation;
import com.baizhi.dao.ArticleDao;
import com.baizhi.entity.Article;
import com.baizhi.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class ArticleServiceImpl implements ArticleService {
   @Autowired
   private ArticleDao articleDao;


    @Override
    @AddCacheAnnotation
    public Map selectAll(int page, int limit) {
        int offset=(page-1)*limit;
        List<Article> list=articleDao.selectAll(offset,limit);
        int count=articleDao.selectCount();
        Map map=new HashMap();
        map.put("data",list);
        map.put("count",count);
        map.put("code",0);
        map.put("msg","");
        return map;
    }



    //app
    @Override
    public List<Article> selectArticleByDate(Integer count) {
        return articleDao.selectArticleByDate(count);
    }
}
